﻿using System;
using System.Threading;

namespace DHelpers.ExtensionsHelper
{
    public static class ExtensionEventHelper
    {
        public static void Raise<T>(this T e, object sender, ref EventHandler<T> eventDelegate) where T : EventArgs
        {
            var tmpObj = Interlocked.CompareExchange(ref eventDelegate, null, null);
            if (tmpObj != null)
            {
                tmpObj(sender, e);
            }
        }
    }
}